package com.gitee.ywj1352.proxy.dynamic.custom;

import com.gitee.ywj1352.proxy.dynamic.jdk.Man;

import java.lang.reflect.Method;

public class YWJProxyInvocation implements YWJInvocationHandler{
    private Man person;

    public Object getInstance(Man target) throws  Exception{
        this.person = target;
        Class<?> aClazz = person.getClass();
        return YWJProxy.newProxyInstance(new YWJClassLoader(),new Class[]{aClazz},this);
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("增强");
        method.invoke(proxy,args);
        System.out.println("增强");
        return proxy;
    }
}
